import { createRouter, createWebHashHistory } from 'vue-router'
import createRouteGuard from './guard'
import home from '../layout/index.vue'

import { myRoutes } from './router'

const routes: any = [
  {
    path: '/:catchAll(.*)', // 不识别的path自动匹配404
    component: () => import('../views/error/404/index.vue'),
  },

  {
    path: '/cvmagic/login',
    title: '登入',
    component: () => import('@/views/login/index.vue'),
  },
  {
    path: '/cvmagic/shopinfo',
    title: '店铺信息',
    component: () => import('@/views/shopinfo/index.vue'),
  },

  {
    path: '/cvmagic/register',
    title: '注册',
    component: () => import('@/views/register/index.vue'),
    redirect: '/cvmagic/register/store',
    children: [
      {
        path: '/cvmagic/register/store',
        component: () => import('@/views/register/components/store/index.vue'),
      },
      {
        path: '/cvmagic/register/qualification',
        name: 'qualification',
        component: () =>
          import('@/views/register/components/qualification/index.vue'),
      },
      {
        path: '/cvmagic/register/shop',
        name: 'shop',
        component: () =>
          import('@/views/register/components/shopinfo/index.vue'),
      },
    ],
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

/**
 * 路由守卫
 */
createRouteGuard(router)

export default router
